application: Add a query-end signal
authorMatthias Clasen <mclasen@redhat.com>
Tue, 22 Jan 2019 01:45:15 +0000 (20:45 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 19 Feb 2019 05:56:31 +0000 (00:56 -0500)
This lets us take just-in-time inhibitors, and makes
the session support a little more real.

gtk/gtkapplication-dbus.c
gtk/gtkapplication.c

index 05a35cc945c2eb84e834392fa7299455dbf752b3..3345a795734ca8a4b5c42580a9b9cf47c8cc5874 100644 (file)
@@ -97,6 +97,7 @@ client_proxy_signal (GDBusProxy  *proxy,
   if (g_str_equal (signal_name, "QueryEndSession"))
     {
       g_debug ("Received QueryEndSession");
+      g_signal_emit_by_name (dbus->impl.application, "query-end");
       send_quit_response (dbus, TRUE, NULL);
     }
   else if (g_str_equal (signal_name, "CancelEndSession"))
@@ -237,6 +238,8 @@ screensaver_signal_portal (GDBusConnection *connection,
         }
       else if (session_state == QUERY_END)
         {
+          g_signal_emit_by_name (dbus->impl.application, "query-end");
+
           g_dbus_proxy_call (dbus->inhibit_proxy,
                              "QueryEndResponse",
                              g_variant_new ("(o)", dbus->session_id),
index 0ae1de11a1246ed93cb303144e3550dd667e4398..7adfc70f03265aedd5ebb35ef15f4b5b1f69b8b2 100644 (file)
 enum {
   WINDOW_ADDED,
   WINDOW_REMOVED,
+  QUERY_END,
   LAST_SIGNAL
 };
 
@@ -653,6 +654,22 @@ gtk_application_class_init (GtkApplicationClass *class)
                   g_cclosure_marshal_VOID__OBJECT,
                   G_TYPE_NONE, 1, GTK_TYPE_WINDOW);
 
+  /**
+   * GtkApplication::query-end:
+   * @application: the #GtkApplication which emitted the signal
+   *
+   * Emitted when the session manager is about to end the session, only
+   * if #GtkApplication::register-session is %TRUE. Applications can
+   * connect to this signal and call gtk_application_inhibit() with
+   * %GTK_APPLICATION_INHIBIT_LOGOUT to delay the end of the session
+   * until state has been saved.
+   */
+  gtk_application_signals[QUERY_END] =
+    g_signal_new (I_("query-end"), GTK_TYPE_APPLICATION, G_SIGNAL_RUN_FIRST,
+                  0,
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE, 0);
   /**
    * GtkApplication:register-session:
    *